﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Caching;

namespace NCacheDClient
{
    public class NCacheDProvider : OutputCacheProvider
    {
        public override object Add(string key, object entry, DateTime utcExpiry)
        {
            var cachedItem = NCacheD.Get<object>(key);
            if (cachedItem == null)
            {
                NCacheD.Put(key, utcExpiry, entry);
                cachedItem = entry;
            }

            return cachedItem;
        }

        public override object Get(string key)
        {
            return NCacheD.Get<object>(key);
        }

        public override void Remove(string key)
        {
            NCacheD.Delete(key);
        }

        public override void Set(string key, object entry, DateTime utcExpiry)
        {
            NCacheD.Put(key, utcExpiry, entry);
        }
    }
}
